#include "oscilloscopescriptable.h"
#include "oscilloscopecanvas.h"
#include <QtScript/QScriptValue>
#include <QtScript/QScriptEngine>

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__) ":(" __FUNCTION__ ")"
#define GET_PTHAT(that) 	cpp_type * that = qscriptvalue_cast<cpp_type*>(thisObject());\
	if(!that)\
		throw context()->throwError(QScriptContext::TypeError, AT": invalid object");

OscilloscopeScriptable::OscilloscopeScriptable(QWidget *parent)
	: OscilloscopeFrame(parent)
{

}

OscilloscopeScriptable::~OscilloscopeScriptable()
{

}

void OscilloscopeScriptable::appendSample(int nSignal, qreal sample)
{
	getOscilloscopeWidget().appendSample(sample, nSignal);
}

bool OscilloscopeScriptable::getEnabledState(int nSignal) const
{
	bool bRet = getOscilloscopeWidget().getEnabledState(nSignal);
	return bRet;
}

bool OscilloscopeScriptable::getStoppedState(int nSignal) const
{
	bool bRet = getOscilloscopeWidget().getStoppedState(nSignal);
	return bRet;
}

void OscilloscopeScriptable::setEnabledState(int nSignal, bool bState)
{
	getOscilloscopeWidget().setEnabledState(bState, nSignal);
}

void OscilloscopeScriptable::setStoppedState(int nSignal, bool bState)
{
	getOscilloscopeWidget().setStoppedState(bState, nSignal);
}
